// 检查手机号
export const checkTel = (tel) =>{
  var reg =/^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$|17[0-9]{1}[0-9]{8}$|19[0-9]{1}[0-9]{8}$/;
  return reg.test(tel);
}
export const jsApiCall=(data ,callback_succ_func ,callback_error_func)=>{  
	//使用原生的，避免初始化appid问题  
	WeixinJSBridge.invoke('getBrandWCPayRequest', {  
		appId:data['appId'],  
		timeStamp: data['timeStamp'],  
		nonceStr: data['nonceStr'],
		package: data['package'],
		signType: data['signType'],
		paySign: data['paySign'],
	},  
	function(res) {  
		var msg = res.err_msg ?res.err_msg :res.errMsg;  
		//WeixinJSBridge.log(msg);  
		switch (msg) {  
			case 'get_brand_wcpay_request:ok': //支付成功时  
				if(callback_succ_func){  
					callback_succ_func(res);  
				}  
				break;  
			default: //支付失败时  
				WeixinJSBridge.log('支付失败!'+msg+',请返回重试.');  
				if(callback_error_func){  
					callback_error_func({msg:msg});  
				}  
				break;  
		}  
	})  
}
//WeixinJSBridge判断
export const wxJsPay=(data ,callback_succ_func ,callback_error_func)=>{
	if (typeof WeixinJSBridge == "undefined") {  
		if (document.addEventListener) {  
			document.addEventListener('WeixinJSBridgeReady', this.jsApiCall, false);  
		} else if (document.attachEvent) {  
			document.attachEvent('WeixinJSBridgeReady', this.jsApiCall);  
			document.attachEvent('onWeixinJSBridgeReady', this.jsApiCall);  
		}  
	} else {  
		jsApiCall(data ,callback_succ_func ,callback_error_func);  
	}  
}
//判断是否是微信内浏览器
export const isWxBrowser=()=>{
	if(window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger"){
		return true
	}else{
		return false
	}
}